/* Includes ------------------------------------------------------------------*/
#include "MyApplication.h"

/* Private define-------------------------------------------------------------*/

/* Private variables----------------------------------------------------------*/
static uint8_t pucSend_Buffer[PUCUART3_SEND_BUFFER_LEN] = {0x00};     //发送缓存
static uint8_t pucRec_Buffer[PUCUART3_REC_BUFFER_LEN] = {0x00};      //接收缓存

static void SendArray(uint8_t* ,uint16_t );
static void SendString(uint8_t* );
static void RS485_Set_SendMode(void);
static void RS485_Set_RecMode(void);
/* Public variables-----------------------------------------------------------*/
UART_t UART3 = 
{
    pucSend_Buffer,
    pucRec_Buffer,

    SendArray,
    SendString,

    RS_485,
    RS485_Set_SendMode,
    RS485_Set_RecMode
};
/* Private function prototypes------------------------------------------------*/

/*
* @name   SendArray
* @brief  发送数组
* @param  p_arr:待发送的数据首地址，len:数组长度
* @retval None   
*/
static void SendArray(uint8_t* p_arr,uint16_t len)
{
    UART3.RS485_Set_SendMode();
    HAL_UART_Transmit_DMA(&huart3,p_arr,len);
}

/*
* @name   SendString
* @brief  发送字符串
* @param  p_str:待发送的字符串的首地址
* @retval None   
*/
static void SendString(uint8_t* p_str)
{

}

/*
* @name   RS485_Set_SendMode
* @brief  RS485设置为发送模式
* @param  None
* @retval None   
*/
static void RS485_Set_SendMode()
{
  //485芯片使能引脚置高电平，设置为发送模式
  HAL_GPIO_WritePin(RS485_DE_nRE_GPIO_Port,RS485_DE_nRE_Pin,GPIO_PIN_SET);
  //开启后延时一会，等硬件反应
  HAL_Delay(1);
}

/*
* @name   RS485_Set_RecMode
* @brief  RS485设置为接收模式
* @param  None
* @retval None   
*/
static void RS485_Set_RecMode()
{
  //485芯片使能引脚置低电平，设置为接收模式
  HAL_GPIO_WritePin(RS485_DE_nRE_GPIO_Port,RS485_DE_nRE_Pin,GPIO_PIN_RESET);
  //开启后延时一会，等硬件反应
  HAL_Delay(1);
}
/********************************************************
  End Of File
********************************************************/
